package at.pp.match3.game;

import android.content.Context;
import android.graphics.Canvas;
import at.pp.match3.game.render.AbstractRenderer;

public abstract class AbstractEngine {

    protected enum GameState {
        Splash, Menu, Countdown, Running, Pause, Lose, Win
    }

    protected int currentTouchX;
    protected int currentTouchY;

    protected int surfaceSizeWidth;
    protected int surfaceSizeHeight;

    protected Context context;

    protected AbstractRenderer renderer;

    protected GameState gameState;
    protected boolean isTouching;
    protected boolean isMoving;

    public AbstractEngine(Context context) {
        this.context = context;
        loadEarlyAssets();
    }

    public abstract void loadEarlyAssets();

    public abstract void updatePhysics();

    public abstract void renderScene(Canvas c);

    public abstract void loadAssets();

    public abstract void processMotionEvent();

    public final GameState getGameState() {
        return gameState;
    }

    public final void setGameState(final GameState gameState) {
        this.gameState = gameState;
    }

    public final void setSurfaceSize(int width, int height) {
        surfaceSizeWidth = width;
        surfaceSizeHeight = height;
    }

    public final AbstractRenderer getRenderer() {
        return renderer;
    }

    public final void setRenderer(final AbstractRenderer renderer) {
        this.renderer = renderer;
    }

    public final Context getContext() {
        return context;
    }

    public final void setTouchedAt(final int x, int y) {
        this.currentTouchX = x;
        this.currentTouchY = y;
    }

    public final void setTouched(final boolean isTouching) {
        this.isTouching = isTouching;
    }

    public final void setMoving(final boolean isMoving) {
        this.isMoving = isMoving;
    }

}
